const express = require('express');
const router = express.Router();
const { activities } = require('../models/activity');

// 收藏/取消收藏活动
router.post('/favorite/:id', (req, res) => {
    const activityId = parseInt(req.params.id);
    const activity = activities.find(a => a.id === activityId);

    if (!activity) {
        return res.status(404).json({ message: '活动未找到' });
    }

    // 切换收藏状态
    activity.isFavorited = !activity.isFavorited;

    res.json({
        message: activity.isFavorited ? '已收藏活动' : '已取消收藏活动',
        activity,
    });
});

module.exports = router;
let activities = [
    { id: 1, name: '活动1', isFavorited: false },
    { id: 2, name: '活动2', isFavorited: false },
    // 可以添加更多活动
];

module.exports = {
    activities,
};
let activities = [
    {
        id: 1,
        name: '活动1',
        publishDate: '2023-10-01',
        address: '地址1',
        eventTime: '2023-10-10 10:00',
        fee: '免费',
        registeredCount: 50,
        hotline: '123456789',
        description: '活动1的简介',
    },
    {
        id: 2,
        name: '活动2',
        publishDate: '2023-10-02',
        address: '地址2',
        eventTime: '2023-10-15 14:00',
        fee: '收费100元',
        registeredCount: 30,
        hotline: '987654321',
        description: '活动2的简介',
    },
    // 可以添加更多活动
];

module.exports = {
    activities,
};
const express = require('express');
const router = express.Router();
const { activities } = require('../models/activity');

// 获取当前的精选活动
router.get('/', (req, res) => {
    res.json({
        message: '当前精选活动',
        activities,
    });
});

module.exports = router;
let activities = [
    {
        id: 1,
        name: '活动1',
        publishDate: '2023-10-01',
        address: '地址1',
        eventTime: '2023-10-10 10:00',
        fee: '免费',
        registeredCount: 50,
        hotline: '123456789',
        description: '活动1的简介',
    },
    {
        id: 2,
        name: '活动2',
        publishDate: '2023-10-02',
        address: '地址2',
        eventTime: '2023-10-15 14:00',
        fee: '收费100元',
        registeredCount: 30,
        hotline: '987654321',
        description: '活动2的简介',
    },
    // 可以添加更多活动
];

module.exports = {
    activities,
};
const express = require('express');
const router = express.Router();
const { activities } = require('../models/activity');

// 第三方分享活动
router.post('/share/:id', (req, res) => {
    const activityId = parseInt(req.params.id);
    const activity = activities.find(a => a.id === activityId);

    if (!activity) {
        return res.status(404).json({ message: '活动未找到' });
    }

    // 这里可以添加分享逻辑，例如调用第三方API
    // 例如：分享至社交媒体的API调用

    res.json({
        message: '活动已成功分享',
        activity,
    });
});

module.exports = router;
let activities = [
    {
        id: 1,
        name: '活动1',
        publishDate: '2023-10-01',
        address: '地址1',
        eventTime: '2023-10-10 10:00',
        fee: '免费',
        registeredCount: 50,
        hotline: '123456789',
        description: '活动1的简介',
    },
    {
        id: 2,
        name: '活动2',
        publishDate: '2023-10-02',
        address: '地址2',
        eventTime: '2023-10-15 14:00',
        fee: '收费100元',
        registeredCount: 30,
        hotline: '987654321',
        description: '活动2的简介',
    },
    // 可以添加更多活动
];

module.exports = {
    activities,
};
const express = require('express');
const router = express.Router();
const { activities } = require('../models/activity');

// 进入报名页面
router.get('/register/:id', (req, res) => {
    const activityId = parseInt(req.params.id);
    const activity = activities.find(a => a.id === activityId);

    if (!activity) {
        return res.status(404).json({ message: '活动未找到' });
    }

    // 返回报名页面的相关信息
    res.json({
        message: '进入报名页面',
        activity,
        registrationLink: `http://localhost:3000/register/${activityId}`, // 假设这是报名链接
    });
});

module.exports = router;
const express = require('express');
const router = express.Router();

// 返回约健体育联盟界面
router.get('/return', (req, res) => {
    // 这里可以添加逻辑，例如记录用户行为、返回特定数据等
    res.json({
        message: '返回约健体育联盟界面',
        success: true,
        redirectUrl: 'http://your-website-url.com', // 替换为约健体育联盟的实际URL
    });
});

module.exports = router;
let activities = [
    {
        id: 1,
        name: '约健体育联盟空中瑜伽50小时TTC项目',
        type: '空中瑜伽',
        price: 5288,
        registeredCount: 50,
        location: '中山北路3300号环环四楼',
        eventTime: '2017-09-13 07:30:18',
        description: '这是一个专业的空中瑜伽TTC项目，适合所有健身爱好者。',
    },
    {
        id: 2,
        name: '健身教练认证培训',
        type: '健身教练培训',
        price: 4888,
        registeredCount: 40,
        location: '广州体育学院',
        eventTime: '2017-10-15 10:00:00',
        description: '该课程包含健身教练理论与实操，帮助您快速成为专业教练。',
    },
    // 可以添加更多活动
];

let users = [
    {
        id: 1,
        name: '张三',
        phone: '13800000000',
        insurance: '意外伤害险',
        paymentMethod: '支付宝',
    },
    {
        id: 2,
        name: '李四',
        phone: '13900000000',
        insurance: '旅游险',
        paymentMethod: '微信支付',
    },
    // 可以添加更多用户
];

module.exports = { activities, users };
const express = require('express');
const router = express.Router();
const { activities, users } = require('../models/activity');

// 获取活动详情与用户信息
router.get('/register/:activityId/:userId', (req, res) => {
    const activityId = parseInt(req.params.activityId);
    const userId = parseInt(req.params.userId);

    // 查找活动
    const activity = activities.find(a => a.id === activityId);
    if (!activity) {
        return res.status(404).json({ message: '活动未找到' });
    }

    // 查找用户
    const user = users.find(u => u.id === userId);
    if (!user) {
        return res.status(404).json({ message: '用户未找到' });
    }

    // 返回活动和用户信息
    res.json({
        message: '获取报名信息成功',
        activity: {
            name: activity.name,
            type: activity.type,
            price: activity.price,
            registeredCount: activity.registeredCount,
            location: activity.location,
            eventTime: activity.eventTime,
            description: activity.description,
        },
        user: {
            name: user.name,
            phone: user.phone,
            insurance: user.insurance,
            paymentMethod: user.paymentMethod,
        },
        registrationNotice: {
            notice: '报名须知：活动前请确保已完成报名确认。',
        },
    });
});

module.exports = router;